<?
session_start();
include_once("includes/common_public_inc.php");

if (isset($_GET["add_fav"]))
	$add_fav = round($_GET["add_fav"]);

if (isset($_GET["remove_fav"]))
	$remove_fav = round($_GET["remove_fav"]);

$tplFav=new TplLoad;
$tplFav->assign("phpself",$_SERVER['PHP_SELF']);
check_valid_user("popup");

if (session_is_registered("valid_user"))
{
	check_valid_user("");
	
	if (isset($add_fav))
	{
		$sql = "insert into $fav_tbl (f_user_id,f_adid) values ('".$_SESSION["valid_user"]."', $add_fav)";
		$res = q($sql);
		$tplFav->assign("fav_added",1);
	}
	else if (isset($remove_fav))
	{
		$sql = "delete from $fav_tbl where f_user_id='".$_SESSION["valid_user"]."' AND f_adid=$remove_fav";
		$res = q($sql);
		$tplFav->assign("fav_removed",1);
	}	
	
}
$tplFav->assign("charset",$set_charset);
$tplFav->display("fav_popup.tpl");
?>